/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ch.bbcnet.awesomeplayer;

import java.awt.Color;
import java.awt.Component;
import java.io.File;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

/**
 *
 * @author esingn
 */
public class MyCellRenderer extends DefaultTableCellRenderer  {
    Color myColor = new Color(221,221,255);
    public MyCellRenderer(){
        super();
    }
    
    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        Component comp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        File exist = new File(value.toString());
        if (isSelected) {
            return comp;
        }

        if (row % 2 == 0) {
            comp.setBackground(myColor);
        }
        else {
            comp.setBackground( table.getBackground() );    
        }
        if(column == 4){
            if (!exist.exists()){
                comp.setBackground(Color.RED);
            }
        }

        return comp;
    }
    public void setColor(Color a){
        myColor = a;
    }
}